<%@page import="Model.ThongTinNguoiNhan"%>
<%@page import="Model.GioHang"%>
<%@page import="Model.User"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="Model.Mobile"%>
<%@page import="Model.LineMobile"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="Model.ConnectDatabase"%>
<%@page import="java.sql.PreparedStatement"%>
 <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Xác nhận thông tin đặt hàng</title>

        <link href="css/style.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" type="text/css" href="menu/menu_style.css" />
        <link rel="stylesheet" href="slide/nivo-slider.css" type="text/css" media="screen" />
        <link rel="stylesheet" href="slide/style.css"" type="text/css"/>
        <script type="text/javascript" src="slide/scripts/jquery-1.4.3.min.js"></script>
        <script type="text/javascript" src="slide/jquery.nivo.slider.pack.js"></script>
        <script type="text/javascript" src="menu/stmenu.js"></script>

        <script type="text/javascript">
            $(window).load(function() {
                $('#slider').nivoSlider();
            });
        </script>
        <link href="tooltip/css/global.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="tooltip/jtip.js"></script>

        <style type="text/css">
            <!--
            .style1 {color: #EE0000}
            -->
        </style>
    </head>

    <body>
        <div id="frame">
            <div id="page">
                <div id="header">
                    <table width="960" cellspacing="0" cellpadding="0" border="0" bgcolor="#e8e8e8" >
                        <tbody>
                            <tr>
                                <td width="300" valign="middle"><img src="image/logo.png" alt="Siêu thị di động"	border="0" />
                                </td>
                                <td width="380" >
                                    <table cellspacing="0" cellpadding="0" border="0" background="image/sea_2.jpg" align="center">
                                        <tbody>
                                            <tr>
                                                <td width="7" align="left"><img border="0" src="image/sea_1.jpg" />
                                                </td>
                                                <td>
                                                    <form style="margin: 0px; padding: 0px;" id="basicsearch" name="topsearch" method="get" action="/BasicSearch.jsp">
                                                        <table cellspacing="0" cellpadding="2">
                                                            <tbody>
                                                                <tr>
                                                                    <td nowrap="nowrap" class="textBold">TÌM KIẾM</td>
                                                                    <td width="100">
                                                                        <input type="text" onfocus="if(this.value=='Từ khóa') this.value='';" onblur="if(this.value=='') this.value='Từ khóa';" value="Từ khóa";style="width: 150px;" name="q" class="form_search" />
                                                                    </td>
                                                                    <td><input type="image" src="image/search_1.jpg" /></td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </form>
                                                </td>
                                                <td align="right"><img border="0" src="image/sea_3.jpg" /></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </td>
                                <td width="280" id="hotline">Hotline: 0973523627
                                    <%User user = (User)session.getAttribute("sessionlogin");%>
                                    <div style="position:absolute; left: 870px; top: 99px;">Chào <%=user.getUsername()%> Thoát</div>

                                </td>

                            </tr>
                        </tbody>
                    </table>

                    <div style="background-color:#E8E8E8;">
                        <a href="http://www.dhtml-menu-builder.com"  style="display:none;visibility:hidden;">Javascript DHTML Drop Down Menu Powered by dhtml-menu-builder.com</a>
                        <script type="text/javascript" src="menu/navigation.js"></script>
                    </div>

                </div>
                <!--        end header -->
                <div id="content">

                    <div id="content">
                        <div>
                            <div style="width:300px;float:left;"><img src="image/shopping.png" /></div><div style="width:auto;float:right"><h3 style="color:blue;">Xem những thông tin bên dưới, Nếu bạn đồng ý hãy nhấn “Đặt mua hàng”</h3>
                                <%
                                     ThongTinNguoiNhan pay = (ThongTinNguoiNhan)session.getAttribute("pay");
if(pay!=null){                                           
                                    
                                %>

                                Tỉnh thành: <%//pay.getProvinceName()%><br>
                                Địa chỉ Giao hàng : <%=pay.getThongTinUser().getDiaChi()%>	<br>
                                Họ tên: <%=pay.getThongTinUser().getHoTen()%><br>
                                Điện thoại: <%=pay.getThongTinUser().getDienThoai()%><br>
                                CMND: <%=pay.getCMND()%><br>
                                Phương thức vận chuyển: <%if (pay.getThongTinUser().getTinh() == 1) {
                                        out.println("Giao hàng tận nơi");
                                    } else {
                                        out.print("Giao hàng qua bưu điện");
                                    }%><br>
                                Phương  thức thanh toán: <%//pay.getPayType()%><br>
                                Ghi chú: <%=pay.getGhiChu()%><br>
<%}%>
                            </div>
                            <% GioHang cart = (GioHang) session.getAttribute("cart");
                                ArrayList<Mobile> listLineMb = null;
                                if (cart != null) {
                                    listLineMb = cart.getGioHang();
                                }
                            %>
                            <table width="100%" border="0" cellspacing="0" cellpadding="5" style="clear:both;">
                                <tr >
                                    <th align="center" class="borderheader" scope="col">ẢNH	</th>
                                    <th align="center" class="borderheader" scope="col">SẢN PHẨM</th>
                                    <th align="center" class="borderheader" scope="col">GIÁ</th>
                                    <th align="center" class="borderheader" scope="col">SỐ LƯỢNG</th>
                                    <th align="center" class="borderheader" scope="col">THÀNH TIỀN</th>
                                </tr>
                                <%for (Mobile lineMb : listLineMb) {
                                        Mobile mb = lineMb;%>
                                <tr>
                                    <td align="center" valign="middle">
                                        <img src="<%=mb.getHinhAnh()%>" width="59" height="88" /></td>
                                    <td align="center" ><%=mb.getTenSP()%></td>
                                    <td align="center"><span class="style1"><%=mb.formatedDiscount()%> VND</span></td>
                                    <td align="center"><%=lineMb.getSoLuong()%></td>
                                    <td align="center"><span class="style1"><%=lineMb.getTotalCurrencyFormat()%> VND</span></td>
                                </tr>
                                <%}%>
                                <tr>
                                    <td colspan="4">&nbsp;</td>
                                    <td><strong>Tiền mua hàng <%=cart.getTotal()%> VND</strong></td>
                                </tr>
                                <tr>
                                    <td colspan="4">&nbsp;</td>
                                    <td><strong>Phí vận chuyển: <%int fee = 0;
                                        if (pay.getThongTinUser().getTinh() == 1) {
                                            fee = 20000;
                                        } else {
                                            fee = 50000;
                                        }
                                    double sum = cart.getSum()+fee;
                                     NumberFormat currency = NumberFormat.getInstance();
                                    %><%=currency.format(fee)%> VND</strong></td>
                                </tr>
                                <tr>
                                    <td colspan="4">&nbsp;</td>
                                    <td>
                                        <div style=
                                             "border: solid 0 #2A82DB; border-top-width:2px; padding:5px;">
                                            <strong>Tổng cộng: <span class="style1"><%=currency.format(sum)%> VND</span></strong>
                                        </div>
                                    </td>
                                </tr>

                                <tr align="center">
                                    <td colspan="6"><form action="cart.jsp" method="get">

                                            <input name="pay" type="button" value="Thay đổi" onclick="window.location='cart.jsp'"/>
                                            <input name="pay" type="button" value="Đặt mua hàng" onclick="window.location='SaveOrder'"/>
                                        </form></td>
                                </tr>
                            </table>

                        </div>

                    </div>


                </div>
                <!--    end content -->
            </div>
            <div id="footer">
                <div id="footerLink"><a href="#">Trang chủ</a>  |<a href="htpp://localhost:8080/tintuc.jsp"> Tin tức</a>  |  <a href="htpp://localhost:8080/khuyenmai.jsp">Khuyến mãi</a>   |  <a href="htpp://localhost:8080/lienhe.jsp" target="_blank">Liên hệ</a>  | <a href="htpp://localhost:8080/sitemap.jsp">Sitemap</a><br />
                    Bản quyền © 2013 SHOP CH4</div>

            </div>
            <!--    end page -->
        </div>
    </body>
</html>